package c.c.b.a.b.a.h;

import c.c.b.a.a.e;
import c.c.b.a.a.g;
import c.c.b.a.a.h;
import c.c.b.a.a.w;
import c.c.b.a.a.x;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import com.pgl.sys.ces.out.ISdkLite;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.logging.Level;
import java.util.logging.Logger;

/* compiled from: Http2Reader */
public final class p implements Closeable {
    public static final Logger e = Logger.getLogger(e.class.getName());
    public final g a;
    public final a b;
    public final boolean c;
    public final c.c.b.a.b.a.h.d.a d;

    /* compiled from: Http2Reader */
    public interface b {
    }

    /* compiled from: Http2Reader */
    public static final class a implements w {
        public final g a;
        public int b;
        public byte c;
        public int d;
        public int e;
        public short f;

        public a(g gVar) {
            this.a = gVar;
        }

        public x a() {
            return this.a.a();
        }

        public long b(e eVar, long j) throws IOException {
            while (true) {
                int i = this.e;
                if (i == 0) {
                    this.a.p((long) this.f);
                    this.f = (short) 0;
                    if ((this.c & 4) != 0) {
                        return -1;
                    }
                    int i2 = this.d;
                    int k = p.k(this.a);
                    this.e = k;
                    this.b = k;
                    byte h = (byte) (this.a.h() & ISdkLite.REGION_UNSET);
                    this.c = (byte) (this.a.h() & ISdkLite.REGION_UNSET);
                    Logger logger = p.e;
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine(e.b(true, this.d, this.b, h, this.c));
                    }
                    int j2 = this.a.j() & Integer.MAX_VALUE;
                    this.d = j2;
                    if (h != (byte) 9) {
                        e.c("%s != TYPE_CONTINUATION", Byte.valueOf(h));
                        throw null;
                    } else if (j2 != i2) {
                        e.c("TYPE_CONTINUATION streamId changed", new Object[0]);
                        throw null;
                    }
                } else {
                    long b = this.a.b(eVar, Math.min(j, (long) i));
                    if (b == -1) {
                        return -1;
                    }
                    this.e = (int) (((long) this.e) - b);
                    return b;
                }
            }
        }

        public void close() throws IOException {
        }
    }

    public p(g gVar, boolean z) {
        this.a = gVar;
        this.c = z;
        a aVar = new a(gVar);
        this.b = aVar;
        this.d = new c.c.b.a.b.a.h.d.a(4096, aVar);
    }

    public static int a(int i, byte b, short s) throws IOException {
        short i2;
        if ((b & 8) != 0) {
            i2 = i2 - 1;
        }
        if (s <= i2) {
            return (short) (i2 - s);
        }
        e.c("PROTOCOL_ERROR padding %s > remaining length %s", Short.valueOf(s), Integer.valueOf(i2));
        throw null;
    }

    public static int k(g gVar) throws IOException {
        return (gVar.h() & ISdkLite.REGION_UNSET) | (((gVar.h() & ISdkLite.REGION_UNSET) << 16) | ((gVar.h() & ISdkLite.REGION_UNSET) << 8));
    }

    public void close() throws IOException {
        this.a.close();
    }

    public final List<c> n(int i, short s, byte b, int i2) throws IOException {
        a aVar = this.b;
        aVar.e = i;
        aVar.b = i;
        aVar.f = s;
        aVar.c = b;
        aVar.d = i2;
        c.c.b.a.b.a.h.d.a aVar2 = this.d;
        while (!aVar2.b.e()) {
            int h = aVar2.b.h() & ISdkLite.REGION_UNSET;
            int d;
            StringBuilder g;
            h e;
            if (h == AesLen.ROOTKEY_COMPONET_LEN) {
                throw new IOException("index == 0");
            } else if ((h & AesLen.ROOTKEY_COMPONET_LEN) == AesLen.ROOTKEY_COMPONET_LEN) {
                h = aVar2.b(h, 127) - 1;
                Object obj = (h < 0 || h > d.a.length - 1) ? null : 1;
                if (obj != null) {
                    aVar2.a.add(d.a[h]);
                } else {
                    d = aVar2.d(h - d.a.length);
                    if (d >= 0) {
                        c[] cVarArr = aVar2.e;
                        if (d <= cVarArr.length - 1) {
                            aVar2.a.add(cVarArr[d]);
                        }
                    }
                    g = c.b.a.a.a.g("Header index too large ");
                    g.append(h + 1);
                    throw new IOException(g.toString());
                }
            } else if (h == 64) {
                e = aVar2.e();
                d.a(e);
                aVar2.c(-1, new c(e, aVar2.e()));
            } else if ((h & 64) == 64) {
                aVar2.c(-1, new c(aVar2.g(aVar2.b(h, 63) - 1), aVar2.e()));
            } else if ((h & 32) == 32) {
                h = aVar2.b(h, 31);
                aVar2.d = h;
                if (h < 0 || h > aVar2.c) {
                    g = c.b.a.a.a.g("Invalid dynamic table size update ");
                    g.append(aVar2.d);
                    throw new IOException(g.toString());
                }
                d = aVar2.h;
                if (h < d) {
                    if (h == 0) {
                        aVar2.f();
                    } else {
                        aVar2.a(d - h);
                    }
                }
            } else if (h == 16 || h == 0) {
                e = aVar2.e();
                d.a(e);
                aVar2.a.add(new c(e, aVar2.e()));
            } else {
                aVar2.a.add(new c(aVar2.g(aVar2.b(h, 15) - 1), aVar2.e()));
            }
        }
        aVar2 = this.d;
        Objects.requireNonNull(aVar2);
        ArrayList arrayList = new ArrayList(aVar2.a);
        aVar2.a.clear();
        return arrayList;
    }

    public void o(b bVar) throws IOException {
        if (!this.c) {
            g gVar = this.a;
            h hVar = e.a;
            h c = gVar.c((long) hVar.v());
            Logger logger = e;
            if (logger.isLoggable(Level.FINE)) {
                logger.fine(c.c.b.a.b.a.e.i("<< CONNECTION %s", c.t()));
            }
            if (!hVar.equals(c)) {
                e.c("Expected a connection header but was %s", c.j());
                throw null;
            }
        } else if (!q(true, bVar)) {
            e.c("Required SETTINGS preface not received", new Object[0]);
            throw null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:155:0x02bd  */
    public boolean q(boolean r19, c.c.b.a.b.a.h.p.b r20) throws java.io.IOException {
        /*
        r18 = this;
        r1 = r18;
        r0 = r20;
        r2 = 0;
        r3 = r1.a;	 Catch:{ IOException -> 0x02e6 }
        r4 = 9;
        r3.a(r4);	 Catch:{ IOException -> 0x02e6 }
        r3 = r1.a;
        r3 = k(r3);
        r4 = 0;
        r5 = 1;
        if (r3 < 0) goto L_0x02d8;
    L_0x0016:
        r6 = 16384; // 0x4000 float:2.2959E-41 double:8.0948E-320;
        if (r3 > r6) goto L_0x02d8;
    L_0x001a:
        r6 = r1.a;
        r6 = r6.h();
        r6 = r6 & 255;
        r6 = (byte) r6;
        if (r19 == 0) goto L_0x0037;
    L_0x0025:
        r7 = 4;
        if (r6 != r7) goto L_0x0029;
    L_0x0028:
        goto L_0x0037;
    L_0x0029:
        r0 = "Expected a SETTINGS frame but was %s";
        r3 = new java.lang.Object[r5];
        r5 = java.lang.Byte.valueOf(r6);
        r3[r2] = r5;
        c.c.b.a.b.a.h.e.c(r0, r3);
        throw r4;
    L_0x0037:
        r7 = r1.a;
        r7 = r7.h();
        r7 = r7 & 255;
        r7 = (byte) r7;
        r8 = r1.a;
        r8 = r8.j();
        r9 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r8 = r8 & r9;
        r9 = e;
        r10 = java.util.logging.Level.FINE;
        r10 = r9.isLoggable(r10);
        if (r10 == 0) goto L_0x005b;
    L_0x0054:
        r10 = c.c.b.a.b.a.h.e.b(r5, r8, r3, r6, r7);
        r9.fine(r10);
    L_0x005b:
        r9 = 2;
        switch(r6) {
            case 0: goto L_0x01ad;
            case 1: goto L_0x00b1;
            case 2: goto L_0x0085;
            case 3: goto L_0x0080;
            case 4: goto L_0x007b;
            case 5: goto L_0x0076;
            case 6: goto L_0x0071;
            case 7: goto L_0x006c;
            case 8: goto L_0x0067;
            default: goto L_0x005f;
        };
    L_0x005f:
        r0 = r1.a;
        r2 = (long) r3;
        r0.p(r2);
        goto L_0x02d7;
    L_0x0067:
        r1.w(r0, r3, r8);
        goto L_0x02d7;
    L_0x006c:
        r1.v(r0, r3, r8);
        goto L_0x02d7;
    L_0x0071:
        r1.u(r0, r3, r7, r8);
        goto L_0x02d7;
    L_0x0076:
        r1.t(r0, r3, r7, r8);
        goto L_0x02d7;
    L_0x007b:
        r1.s(r0, r3, r7, r8);
        goto L_0x02d7;
    L_0x0080:
        r1.r(r0, r3, r8);
        goto L_0x02d7;
    L_0x0085:
        r6 = 5;
        if (r3 != r6) goto L_0x00a3;
    L_0x0088:
        if (r8 == 0) goto L_0x009b;
    L_0x008a:
        r2 = r1.a;
        r2.j();
        r2 = r1.a;
        r2.h();
        r0 = (c.c.b.a.b.a.h.g.e) r0;
        java.util.Objects.requireNonNull(r0);
        goto L_0x02d7;
    L_0x009b:
        r0 = new java.lang.Object[r2];
        r2 = "TYPE_PRIORITY streamId == 0";
        c.c.b.a.b.a.h.e.c(r2, r0);
        throw r4;
    L_0x00a3:
        r0 = new java.lang.Object[r5];
        r3 = java.lang.Integer.valueOf(r3);
        r0[r2] = r3;
        r2 = "TYPE_PRIORITY length: %d != 5";
        c.c.b.a.b.a.h.e.c(r2, r0);
        throw r4;
    L_0x00b1:
        if (r8 == 0) goto L_0x01a5;
    L_0x00b3:
        r6 = r7 & 1;
        if (r6 == 0) goto L_0x00b9;
    L_0x00b7:
        r6 = 1;
        goto L_0x00ba;
    L_0x00b9:
        r6 = 0;
    L_0x00ba:
        r10 = r7 & 8;
        if (r10 == 0) goto L_0x00c8;
    L_0x00be:
        r10 = r1.a;
        r10 = r10.h();
        r10 = r10 & 255;
        r10 = (short) r10;
        goto L_0x00c9;
    L_0x00c8:
        r10 = 0;
    L_0x00c9:
        r11 = r7 & 32;
        if (r11 == 0) goto L_0x00df;
    L_0x00cd:
        r11 = r1.a;
        r11.j();
        r11 = r1.a;
        r11.h();
        r11 = r0;
        r11 = (c.c.b.a.b.a.h.g.e) r11;
        java.util.Objects.requireNonNull(r11);
        r3 = r3 + -5;
    L_0x00df:
        r3 = a(r3, r7, r10);
        r15 = r1.n(r3, r10, r7, r8);
        r0 = (c.c.b.a.b.a.h.g.e) r0;
        r3 = c.c.b.a.b.a.h.g.this;
        r3 = r3.h0(r8);
        if (r3 == 0) goto L_0x0111;
    L_0x00f1:
        r11 = c.c.b.a.b.a.h.g.this;
        r0 = r11.h;
        r3 = new c.c.b.a.b.a.h.j;
        r13 = new java.lang.Object[r9];
        r4 = r11.d;
        r13[r2] = r4;
        r2 = java.lang.Integer.valueOf(r8);
        r13[r5] = r2;
        r12 = "OkHttp %s Push Headers[%s]";
        r10 = r3;
        r14 = r8;
        r16 = r6;
        r10.m5315init(r11, r12, r13, r14, r15, r16);
        r0.execute(r3);
        goto L_0x02d7;
    L_0x0111:
        r3 = c.c.b.a.b.a.h.g.this;
        monitor-enter(r3);
        r7 = c.c.b.a.b.a.h.g.this;	 Catch:{ all -> 0x01a2 }
        r7 = r7.o(r8);	 Catch:{ all -> 0x01a2 }
        if (r7 != 0) goto L_0x0169;
    L_0x011c:
        r12 = c.c.b.a.b.a.h.g.this;	 Catch:{ all -> 0x01a2 }
        r4 = r12.g;	 Catch:{ all -> 0x01a2 }
        if (r4 == 0) goto L_0x0125;
    L_0x0122:
        monitor-exit(r3);	 Catch:{ all -> 0x01a2 }
        goto L_0x02d7;
    L_0x0125:
        r4 = r12.e;	 Catch:{ all -> 0x01a2 }
        if (r8 > r4) goto L_0x012c;
    L_0x0129:
        monitor-exit(r3);	 Catch:{ all -> 0x01a2 }
        goto L_0x02d7;
    L_0x012c:
        r4 = r8 % 2;
        r7 = r12.f;	 Catch:{ all -> 0x01a2 }
        r7 = r7 % r9;
        if (r4 != r7) goto L_0x0136;
    L_0x0133:
        monitor-exit(r3);	 Catch:{ all -> 0x01a2 }
        goto L_0x02d7;
    L_0x0136:
        r4 = new c.c.b.a.b.a.h.q;	 Catch:{ all -> 0x01a2 }
        r13 = 0;
        r10 = r4;
        r11 = r8;
        r14 = r6;
        r10.m908init(r11, r12, r13, r14, r15);	 Catch:{ all -> 0x01a2 }
        r6 = c.c.b.a.b.a.h.g.this;	 Catch:{ all -> 0x01a2 }
        r6.e = r8;	 Catch:{ all -> 0x01a2 }
        r6 = r6.c;	 Catch:{ all -> 0x01a2 }
        r7 = java.lang.Integer.valueOf(r8);	 Catch:{ all -> 0x01a2 }
        r6.put(r7, r4);	 Catch:{ all -> 0x01a2 }
        r6 = c.c.b.a.b.a.h.g.s;	 Catch:{ all -> 0x01a2 }
        r7 = new c.c.b.a.b.a.h.m;	 Catch:{ all -> 0x01a2 }
        r10 = "OkHttp %s stream %d";
        r9 = new java.lang.Object[r9];	 Catch:{ all -> 0x01a2 }
        r11 = c.c.b.a.b.a.h.g.this;	 Catch:{ all -> 0x01a2 }
        r11 = r11.d;	 Catch:{ all -> 0x01a2 }
        r9[r2] = r11;	 Catch:{ all -> 0x01a2 }
        r2 = java.lang.Integer.valueOf(r8);	 Catch:{ all -> 0x01a2 }
        r9[r5] = r2;	 Catch:{ all -> 0x01a2 }
        r7.m5318init(r0, r10, r9, r4);	 Catch:{ all -> 0x01a2 }
        r6.execute(r7);	 Catch:{ all -> 0x01a2 }
        monitor-exit(r3);	 Catch:{ all -> 0x01a2 }
        goto L_0x02d7;
    L_0x0169:
        monitor-exit(r3);	 Catch:{ all -> 0x01a2 }
        monitor-enter(r7);
        r7.g = r5;	 Catch:{ all -> 0x019f }
        r0 = r7.f;	 Catch:{ all -> 0x019f }
        if (r0 != 0) goto L_0x017b;
    L_0x0171:
        r7.f = r15;	 Catch:{ all -> 0x019f }
        r0 = r7.b();	 Catch:{ all -> 0x019f }
        r7.notifyAll();	 Catch:{ all -> 0x019f }
        goto L_0x018e;
    L_0x017b:
        r0 = new java.util.ArrayList;	 Catch:{ all -> 0x019f }
        r0.<init>();	 Catch:{ all -> 0x019f }
        r2 = r7.f;	 Catch:{ all -> 0x019f }
        r0.addAll(r2);	 Catch:{ all -> 0x019f }
        r0.add(r4);	 Catch:{ all -> 0x019f }
        r0.addAll(r15);	 Catch:{ all -> 0x019f }
        r7.f = r0;	 Catch:{ all -> 0x019f }
        r0 = 1;
    L_0x018e:
        monitor-exit(r7);	 Catch:{ all -> 0x019f }
        if (r0 != 0) goto L_0x0198;
    L_0x0191:
        r0 = r7.d;
        r2 = r7.c;
        r0.v(r2);
    L_0x0198:
        if (r6 == 0) goto L_0x02d7;
    L_0x019a:
        r7.f();
        goto L_0x02d7;
    L_0x019f:
        r0 = move-exception;
        monitor-exit(r7);	 Catch:{ all -> 0x019f }
        throw r0;
    L_0x01a2:
        r0 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x01a2 }
        throw r0;
    L_0x01a5:
        r0 = "PROTOCOL_ERROR: TYPE_HEADERS streamId == 0";
        r2 = new java.lang.Object[r2];
        c.c.b.a.b.a.h.e.c(r0, r2);
        throw r4;
    L_0x01ad:
        if (r8 == 0) goto L_0x02cf;
    L_0x01af:
        r6 = r7 & 1;
        if (r6 == 0) goto L_0x01b6;
    L_0x01b3:
        r17 = 1;
        goto L_0x01b8;
    L_0x01b6:
        r17 = 0;
    L_0x01b8:
        r6 = r7 & 32;
        if (r6 == 0) goto L_0x01be;
    L_0x01bc:
        r6 = 1;
        goto L_0x01bf;
    L_0x01be:
        r6 = 0;
    L_0x01bf:
        if (r6 != 0) goto L_0x02c7;
    L_0x01c1:
        r4 = r7 & 8;
        if (r4 == 0) goto L_0x01cf;
    L_0x01c5:
        r4 = r1.a;
        r4 = r4.h();
        r4 = r4 & 255;
        r4 = (short) r4;
        goto L_0x01d0;
    L_0x01cf:
        r4 = 0;
    L_0x01d0:
        r3 = a(r3, r7, r4);
        r6 = r1.a;
        r0 = (c.c.b.a.b.a.h.g.e) r0;
        r7 = c.c.b.a.b.a.h.g.this;
        r7 = r7.h0(r8);
        if (r7 == 0) goto L_0x0231;
    L_0x01e0:
        r11 = c.c.b.a.b.a.h.g.this;
        java.util.Objects.requireNonNull(r11);
        r15 = new c.c.b.a.a.e;
        r15.m7918init();
        r12 = (long) r3;
        r6.a(r12);
        r6.b(r15, r12);
        r6 = r15.b;
        r0 = (r6 > r12 ? 1 : (r6 == r12 ? 0 : -1));
        if (r0 != 0) goto L_0x0215;
    L_0x01f7:
        r0 = r11.h;
        r6 = new c.c.b.a.b.a.h.k;
        r13 = new java.lang.Object[r9];
        r7 = r11.d;
        r13[r2] = r7;
        r2 = java.lang.Integer.valueOf(r8);
        r13[r5] = r2;
        r12 = "OkHttp %s Push Data[%s]";
        r10 = r6;
        r14 = r8;
        r16 = r3;
        r10.m5316init(r11, r12, r13, r14, r15, r16, r17);
        r0.execute(r6);
        goto L_0x02c0;
    L_0x0215:
        r0 = new java.io.IOException;
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r4 = r15.b;
        r2.append(r4);
        r4 = " != ";
        r2.append(r4);
        r2.append(r3);
        r2 = r2.toString();
        r0.<init>(r2);
        throw r0;
    L_0x0231:
        r7 = c.c.b.a.b.a.h.g.this;
        r7 = r7.o(r8);
        if (r7 != 0) goto L_0x0246;
    L_0x0239:
        r0 = c.c.b.a.b.a.h.g.this;
        r2 = c.c.b.a.b.a.h.b.PROTOCOL_ERROR;
        r0.r(r8, r2);
        r2 = (long) r3;
        r6.p(r2);
        goto L_0x02c0;
    L_0x0246:
        r0 = r7.h;
        r8 = (long) r3;
        java.util.Objects.requireNonNull(r0);
    L_0x024c:
        r10 = 0;
        r3 = (r8 > r10 ? 1 : (r8 == r10 ? 0 : -1));
        if (r3 <= 0) goto L_0x02bb;
    L_0x0252:
        r3 = c.c.b.a.b.a.h.q.this;
        monitor-enter(r3);
        r12 = r0.e;	 Catch:{ all -> 0x02b8 }
        r13 = r0.b;	 Catch:{ all -> 0x02b8 }
        r13 = r13.b;	 Catch:{ all -> 0x02b8 }
        r13 = r13 + r8;
        r10 = r0.c;	 Catch:{ all -> 0x02b8 }
        r15 = (r13 > r10 ? 1 : (r13 == r10 ? 0 : -1));
        if (r15 <= 0) goto L_0x0264;
    L_0x0262:
        r10 = 1;
        goto L_0x0265;
    L_0x0264:
        r10 = 0;
    L_0x0265:
        monitor-exit(r3);	 Catch:{ all -> 0x02b8 }
        if (r10 == 0) goto L_0x027e;
    L_0x0268:
        r6.p(r8);
        r0 = c.c.b.a.b.a.h.q.this;
        r2 = c.c.b.a.b.a.h.b.FLOW_CONTROL_ERROR;
        r3 = r0.d(r2);
        if (r3 != 0) goto L_0x0276;
    L_0x0275:
        goto L_0x02bb;
    L_0x0276:
        r3 = r0.d;
        r0 = r0.c;
        r3.r(r0, r2);
        goto L_0x02bb;
    L_0x027e:
        if (r12 == 0) goto L_0x0284;
    L_0x0280:
        r6.p(r8);
        goto L_0x02bb;
    L_0x0284:
        r3 = r0.a;
        r10 = r6.b(r3, r8);
        r12 = -1;
        r3 = (r10 > r12 ? 1 : (r10 == r12 ? 0 : -1));
        if (r3 == 0) goto L_0x02b2;
    L_0x0290:
        r8 = r8 - r10;
        r3 = c.c.b.a.b.a.h.q.this;
        monitor-enter(r3);
        r10 = r0.b;	 Catch:{ all -> 0x02af }
        r11 = r10.b;	 Catch:{ all -> 0x02af }
        r13 = 0;
        r15 = (r11 > r13 ? 1 : (r11 == r13 ? 0 : -1));
        if (r15 != 0) goto L_0x02a0;
    L_0x029e:
        r11 = 1;
        goto L_0x02a1;
    L_0x02a0:
        r11 = 0;
    L_0x02a1:
        r12 = r0.a;	 Catch:{ all -> 0x02af }
        r10.n(r12);	 Catch:{ all -> 0x02af }
        if (r11 == 0) goto L_0x02ad;
    L_0x02a8:
        r10 = c.c.b.a.b.a.h.q.this;	 Catch:{ all -> 0x02af }
        r10.notifyAll();	 Catch:{ all -> 0x02af }
    L_0x02ad:
        monitor-exit(r3);	 Catch:{ all -> 0x02af }
        goto L_0x024c;
    L_0x02af:
        r0 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x02af }
        throw r0;
    L_0x02b2:
        r0 = new java.io.EOFException;
        r0.<init>();
        throw r0;
    L_0x02b8:
        r0 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x02b8 }
        throw r0;
    L_0x02bb:
        if (r17 == 0) goto L_0x02c0;
    L_0x02bd:
        r7.f();
    L_0x02c0:
        r0 = r1.a;
        r2 = (long) r4;
        r0.p(r2);
        goto L_0x02d7;
    L_0x02c7:
        r0 = "PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA";
        r2 = new java.lang.Object[r2];
        c.c.b.a.b.a.h.e.c(r0, r2);
        throw r4;
    L_0x02cf:
        r0 = "PROTOCOL_ERROR: TYPE_DATA streamId == 0";
        r2 = new java.lang.Object[r2];
        c.c.b.a.b.a.h.e.c(r0, r2);
        throw r4;
    L_0x02d7:
        return r5;
    L_0x02d8:
        r0 = "FRAME_SIZE_ERROR: %s";
        r5 = new java.lang.Object[r5];
        r3 = java.lang.Integer.valueOf(r3);
        r5[r2] = r3;
        c.c.b.a.b.a.h.e.c(r0, r5);
        throw r4;
    L_0x02e6:
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.a.h.p.q(boolean, c.c.b.a.b.a.h.p$b):boolean");
    }

    public final void r(b bVar, int i, int i2) throws IOException {
        if (i != 4) {
            e.c("TYPE_RST_STREAM length: %d != 4", Integer.valueOf(i));
            throw null;
        } else if (i2 != 0) {
            b a = b.a(this.a.j());
            if (a != null) {
                g.e eVar = (g.e) bVar;
                if (g.this.h0(i2)) {
                    g gVar = g.this;
                    gVar.h.execute(new l(gVar, "OkHttp %s Push Reset[%s]", new Object[]{gVar.d, Integer.valueOf(i2)}, i2, a));
                    return;
                }
                q v = g.this.v(i2);
                if (v != null) {
                    synchronized (v) {
                        if (v.l == null) {
                            v.l = a;
                            v.notifyAll();
                        }
                    }
                    return;
                }
                return;
            }
            e.c("TYPE_RST_STREAM unexpected error code: %d", Integer.valueOf(i));
            throw null;
        } else {
            e.c("TYPE_RST_STREAM streamId == 0", new Object[0]);
            throw null;
        }
    }

    public final void s(b bVar, int i, byte b, int i2) throws IOException {
        q[] qVarArr = null;
        int i3 = 0;
        if (i2 != 0) {
            e.c("TYPE_SETTINGS streamId != 0", new Object[0]);
            throw null;
        } else if ((b & 1) != 0) {
            if (i == 0) {
                Objects.requireNonNull((g.e) bVar);
            } else {
                e.c("FRAME_SIZE_ERROR ack frame should be empty!", new Object[0]);
                throw null;
            }
        } else if (i % 6 == 0) {
            int j;
            long j2;
            v vVar = new v();
            for (int i4 = 0; i4 < i; i4 += 6) {
                int i5 = this.a.i();
                j = this.a.j();
                if (i5 != 2) {
                    if (i5 == 3) {
                        i5 = 4;
                    } else if (i5 == 4) {
                        i5 = 7;
                        if (j < 0) {
                            e.c("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1", new Object[0]);
                            throw null;
                        }
                    } else if (i5 == 5 && (j < 16384 || j > 16777215)) {
                        e.c("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s", Integer.valueOf(j));
                        throw null;
                    }
                } else if (!(j == 0 || j == 1)) {
                    e.c("PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1", new Object[0]);
                    throw null;
                }
                vVar.a(i5, j);
            }
            g.e eVar = (g.e) bVar;
            synchronized (g.this) {
                i = g.this.m.b();
                v vVar2 = g.this.m;
                Objects.requireNonNull(vVar2);
                for (j = 0; j < 10; j++) {
                    if ((((1 << j) & vVar.a) != 0 ? 1 : null) != null) {
                        vVar2.a(j, vVar.b[j]);
                    }
                }
                ExecutorService executorService = g.s;
                executorService.execute(new o(eVar, "OkHttp %s ACK Settings", new Object[]{g.this.d}, vVar));
                int b2 = g.this.m.b();
                if (b2 == -1 || b2 == i) {
                    j2 = 0;
                } else {
                    j2 = (long) (b2 - i);
                    g gVar = g.this;
                    if (!gVar.n) {
                        gVar.k += j2;
                        if (j2 > 0) {
                            gVar.notifyAll();
                        }
                        g.this.n = true;
                    }
                    if (!g.this.c.isEmpty()) {
                        qVarArr = (q[]) g.this.c.values().toArray(new q[g.this.c.size()]);
                    }
                }
                executorService.execute(new n(eVar, "OkHttp %s settings", g.this.d));
            }
            if (qVarArr != null) {
                int i6 = (j2 > 0 ? 1 : (j2 == 0 ? 0 : -1));
                if (i6 != 0) {
                    i2 = qVarArr.length;
                    while (i3 < i2) {
                        q qVar = qVarArr[i3];
                        synchronized (qVar) {
                            qVar.b += j2;
                            if (i6 > 0) {
                                qVar.notifyAll();
                            }
                        }
                        i3++;
                    }
                }
            }
        } else {
            e.c("TYPE_SETTINGS length %% 6 != 0: %s", Integer.valueOf(i));
            throw null;
        }
    }

    public final void t(b bVar, int i, byte b, int i2) throws IOException {
        if (i2 != 0) {
            short h = (b & 8) != 0 ? (short) (this.a.h() & ISdkLite.REGION_UNSET) : (short) 0;
            int j = this.a.j() & Integer.MAX_VALUE;
            List n = n(a(i - 4, b, h), h, b, i2);
            g gVar = g.this;
            synchronized (gVar) {
                if (gVar.r.contains(Integer.valueOf(j))) {
                    gVar.r(j, b.PROTOCOL_ERROR);
                    return;
                }
                gVar.r.add(Integer.valueOf(j));
                gVar.h.execute(new i(gVar, "OkHttp %s Push Request[%s]", new Object[]{gVar.d, Integer.valueOf(j)}, j, n));
                return;
            }
        }
        e.c("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0", new Object[0]);
        throw null;
    }

    public final void u(b bVar, int i, byte b, int i2) throws IOException {
        if (i != 8) {
            e.c("TYPE_PING length != 8: %s", Integer.valueOf(i));
            throw null;
        } else if (i2 == 0) {
            int j = this.a.j();
            int j2 = this.a.j();
            g.e eVar = (g.e) bVar;
            if (((b & 1) != 0 ? 1 : null) != null) {
                synchronized (g.this) {
                }
                return;
            }
            g.s.execute(new h(r4, "OkHttp %s ping %08x%08x", new Object[]{g.this.d, Integer.valueOf(j), Integer.valueOf(j2)}, true, j, j2, null));
        } else {
            e.c("TYPE_PING streamId != 0", new Object[0]);
            throw null;
        }
    }

    public final void v(b bVar, int i, int i2) throws IOException {
        int i3 = 0;
        if (i < 8) {
            e.c("TYPE_GOAWAY length < 8: %s", Integer.valueOf(i));
            throw null;
        } else if (i2 == 0) {
            i2 = this.a.j();
            i -= 8;
            if (b.a(this.a.j()) != null) {
                q[] qVarArr;
                h hVar = h.e;
                if (i > 0) {
                    hVar = this.a.c((long) i);
                }
                g.e eVar = (g.e) bVar;
                Objects.requireNonNull(eVar);
                hVar.v();
                synchronized (g.this) {
                    qVarArr = (q[]) g.this.c.values().toArray(new q[g.this.c.size()]);
                    g.this.g = true;
                }
                i = qVarArr.length;
                while (i3 < i) {
                    q qVar = qVarArr[i3];
                    if (qVar.c > i2 && qVar.c()) {
                        b bVar2 = b.REFUSED_STREAM;
                        synchronized (qVar) {
                            if (qVar.l == null) {
                                qVar.l = bVar2;
                                qVar.notifyAll();
                            }
                        }
                        g.this.v(qVar.c);
                    }
                    i3++;
                }
                return;
            }
            e.c("TYPE_GOAWAY unexpected error code: %d", Integer.valueOf(this.a.j()));
            throw null;
        } else {
            e.c("TYPE_GOAWAY streamId != 0", new Object[0]);
            throw null;
        }
    }

    public final void w(b bVar, int i, int i2) throws IOException {
        if (i == 4) {
            long j = ((long) this.a.j()) & 2147483647L;
            i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
            if (i != 0) {
                g.e eVar = (g.e) bVar;
                if (i2 == 0) {
                    synchronized (g.this) {
                        g gVar = g.this;
                        gVar.k += j;
                        gVar.notifyAll();
                    }
                    return;
                }
                q o = g.this.o(i2);
                if (o != null) {
                    synchronized (o) {
                        o.b += j;
                        if (i > 0) {
                            o.notifyAll();
                        }
                    }
                    return;
                }
                return;
            }
            e.c("windowSizeIncrement was 0", Long.valueOf(j));
            throw null;
        }
        e.c("TYPE_WINDOW_UPDATE length !=4: %s", Integer.valueOf(i));
        throw null;
    }
}
